package com.mgface.framework.configuration;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.SearchStrategy;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.annotation.Order;
import org.springframework.core.convert.ConversionService;
import org.springframework.format.support.DefaultFormattingConversionService;

import com.mgface.framework.utility.StringToDateConverter;

@Configuration
@Order(3)
public class ConditionConfiguration {
	private final static Logger log = LogManager.getLogger(BeansConfiguration.class);

	@Bean(name = "conversionService")
	@ConditionalOnMissingBean(value = ConversionService.class, search = SearchStrategy.ALL)
	public ConversionService conversionService() {
		log.info(">>>>>>初始化[conversionService],order[3]<<<<<<");
		DefaultFormattingConversionService conversionService = new DefaultFormattingConversionService(true);
		conversionService.addConverter(new StringToDateConverter());
		return conversionService;
	}
}
